[FLINK-39306][flink-autoscaler] Non-source vertices do not use per-second rate metrics, producing inaccurate scaling decisions#1078
Open
Dennis-Mircea wants to merge 1 commit intoapache:mainfrom
Conversation
…cond rate metrics, producing inaccurate scaling decisions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixes the inaccurate scaling metric computation for non-source vertices by enabling per-second rate metrics (
numRecordsInPerSecond/numRecordsOutPerSecond) collection and consumption across the full autoscaler pipeline, and replaces endpoint-only getRate() with spike-resilient alternatives for gauge metrics likeLAG.JIRA: https://issues.apache.org/jira/browse/FLINK-39306
Brief change log
FlinkMetric: AddedNUM_RECORDS_IN_PER_SECandNUM_RECORDS_OUT_PER_SECenum entries to match Flink'snumRecordsInPerSecond/numRecordsOutPerSecondtask-level metrics.ScalingMetric: AddedNUM_RECORDS_IN_PER_SECONDandNUM_RECORDS_OUT_PER_SECONDscaling metric entries for storing per-second rates in the metrics history.ScalingMetricCollector: ExtendedgetFilteredVertexMetricNamesto requestNUM_RECORDS_IN_PER_SECandNUM_RECORDS_OUT_PER_SECfor non-source vertices (previously only source-specific metrics were requested).ScalingMetrics: ExtendedcomputeDataRateMetricsto storeNUM_RECORDS_IN_PER_SECONDandNUM_RECORDS_OUT_PER_SECONDin the collected scaling metrics for non-source vertices when available.ScalingMetricEvaluator:getAverageWithRateFallback(perSecondMetric, accumulatedMetric, ...)- triesgetAverage(perSecondMetric)first (direct per-second rate from Flink), falls back togetRate(accumulatedMetric)(endpoint-based delta from accumulated counters) when the per-second metric is unavailable.getAverageRate(metric, ...)- computes the average of per-interval deltas across the full metrics window, replacing the spike-susceptible endpoint-onlygetRate()for gauge metrics like LAG.getRate(NUM_RECORDS_IN, ...)/getRate(NUM_RECORDS_OUT, ...)calls inisProcessingBacklog,evaluateMetrics,computeEdgeOutputRatio, andcomputeEdgeDataRatewithgetAverageWithRateFallback(NUM_RECORDS_IN_PER_SECOND, NUM_RECORDS_IN, ...)/getAverageWithRateFallback(NUM_RECORDS_OUT_PER_SECOND, NUM_RECORDS_OUT, ...).getRate(LAG, ...)incomputeTargetDataRatewithgetAverageRate(LAG, ...)to avoid diluted lag rate estimation when the metrics window is large.JobAutoScalerImplTest: Fixed flakytestMetricReportingby injecting a deterministicClockviaautoscaler.setClock()to guarantee distinct timestamps across metric collections, avoiding the timestamp collision that caused the metrics history to stay at size 1.Verifying this change
This change can be verified by existing unit tests after the flaky test fix. Additional UTs to be added to validate:
getAverageWithRateFallbackreturns the per-second average when available and falls back to getRate when it is not.getAverageRatecomputes the correct average of per-interval deltas and is resilient to spikes diluted over a large window.NUM_RECORDS_IN_PER_SECOND/NUM_RECORDS_OUT_PER_SECOND.Does this pull request potentially affect one of the following parts:
CustomResourceDescriptors: noDocumentation